//
//  ZhuxiaoViewController.m
//  AILove
//
//  Created by 甘世清 on 2023/12/25.
//

#import "ZhuxiaoViewController.h"

#import "LoginViewController.h"
@interface ZhuxiaoViewController ()

@end

@implementation ZhuxiaoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.zx_navTitle = SQNSLocalString(@"注销账号");
    // Do any additional setup after loading the view.
}

-(void)SQ_UIViewForSelfView{
    UIImageView * image = [[UIImageView alloc]init];
    image.image = SQGetImage(@"警告");
    image.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:image];
    [image mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo(36);
        make.top.equalTo(self.zx_navBar.mas_bottom).offset(30);
    }];
    UILabel * titlabel = [[UILabel alloc]init];
    titlabel.text = SQNSLocalString(@"警告，您即将注销您的帐号");
    titlabel.font = FONT_MEDIUM(18);
    titlabel.textColor = SQColor(@"#CCCCCC");
    [self.view addSubview:titlabel];
    [titlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.view);
        make.top.equalTo(image.mas_bottom).offset(16);
    }];
    
    YYLabel * label3 = [[YYLabel alloc]initWithFrame:CGRectMake(16, TopHeight+154, SCREEN_WIDETH-32, 72)];
    label3.textVerticalAlignment = YYTextVerticalAlignmentCenter;
    label3.textAlignment = NSTextAlignmentCenter;
    label3.numberOfLines = 0;
    [self.view addSubview:label3];
    NSDictionary *attributes = @{NSFontAttributeName:FONT_MEDIUM(15) , NSForegroundColorAttributeName: SQColor999999};
    NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:SQNSLocalString(@"账号注销为不可逆结果，注销账号后，所有个人账号相关VIP会员身份、钻石充值数额，均进行销毁。还请您慎重考虑。") attributes:attributes];
   
    //设置高亮色和点击事件
    [text yy_setTextHighlightRange:[[text string] rangeOfString:SQNSLocalString(@"不可逆结果")] color:SQColor(@"#FFFFFF") backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
       
    }];
    //设置高亮色和点击事件
    [text yy_setTextHighlightRange:[[text string] rangeOfString:SQNSLocalString(@"所有个人账号相关VIP会员身份、钻石充值数额，均进行销毁")] color:SQColor(@"#FFFFFF") backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) {
        
    }];
    
    label3.attributedText = text;
    
    HeaderView * btn = [[HeaderView alloc]init];
    btn.font = FONT_BOLD(16);
    btn.text = SQNSLocalString(@"确认注销");
    btn.layer.cornerRadius = 25;
    btn.headerImage.image = SQGetImage(@"按钮背景");
    [btn.btn addTarget:self action:@selector(SQ_buttonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn];
    [btn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.view.mas_bottom).offset(-50);
        make.height.mas_equalTo(50);
        make.width.mas_equalTo(SCREEN_WIDETH-40);
        make.centerX.equalTo(self.view);
    }];
}

-(void)SQ_buttonClick{
    WS(weakSelf);
    UIAlertController * alert = [UIAlertController alertControllerWithTitle:SQNSLocalString(@"提示") message:SQNSLocalString(@"您确定要注销幻想社交?") preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction * co1 = [UIAlertAction actionWithTitle:SQNSLocalString(@"点错了") style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
       
    }];
    UIAlertAction * co2 = [UIAlertAction actionWithTitle:SQNSLocalString(@"确定") style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        [weakSelf SQ_querenzhuxiao];
    }];
    [alert addAction:co2];
    [alert addAction:co1];
    [co2 setValue:SQColor(@"#999999") forKey:@"titleTextColor"];
    [co1 setValue:SQColor(@"#CC28FD") forKey:@"titleTextColor"];
    [self presentViewController:alert animated:YES completion:nil];
}
-(void)SQ_querenzhuxiao{
    [YJProgressHUD SQ_showMsgWithoutView:@""];
    [HttpTool post:Url16 paramDic:[NSMutableDictionary new] successBlock:^(BaseModel * _Nonnull httpModel) {
        [Manager SQ_removeObjectForKey:@"account"];
        [UserModel clearLocalUserModel];
        UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:[[LoginViewController alloc]init]];
         self.view.window.rootViewController = nav;
        } andFailBloc:^(BaseModel * _Nonnull httpModel, NSError * _Nullable error) {
            [YJProgressHUD showMsgWithoutView:httpModel.message];
    }];
   
}

@end
